cmake_minimum_required(VERSION 2.8)

set(CMAKE_CXX_STANDARD 17)

project(dev_rs485 CXX)

if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
    message(STATUS "current arch is x86_64")
    include_directories(${CMAKE_SOURCE_DIR}/thirdParty/libmodbus-3.1.10/x86lib/include/modbus)
    link_directories(${CMAKE_SOURCE_DIR}/thirdParty/libmodbus-3.1.10/x86lib/lib)

    include_directories(${CMAKE_SOURCE_DIR}/thirdParty/mosquitto-2.0.8/build/x86lib/include)
    link_directories(${CMAKE_SOURCE_DIR}/thirdParty/mosquitto-2.0.8/build/x86lib/lib)

    include_directories(${CMAKE_SOURCE_DIR}/thirdParty/yaml-cpp/build/x86lib/include)
    link_directories(${CMAKE_SOURCE_DIR}/thirdParty/yaml-cpp/build/x86lib/lib)

    include_directories(${CMAKE_SOURCE_DIR}/thirdParty/bluez/x86lib/include)
    link_directories(${CMAKE_SOURCE_DIR}/thirdParty/bluez/x86lib/lib)

elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
    message(STATUS "current arch is aarch64")
    include_directories(${CMAKE_SOURCE_DIR}/thirdParty/libmodbus-3.1.10/arch64lib/include/modbus)
    link_directories(${CMAKE_SOURCE_DIR}/thirdParty/libmodbus-3.1.10/arch64lib/lib)

    include_directories(${CMAKE_SOURCE_DIR}/thirdParty/mosquitto-2.0.8/build/aarch64lib/include)
    link_directories(${CMAKE_SOURCE_DIR}/thirdParty/mosquitto-2.0.8/build/aarch64lib/lib)

    include_directories(${CMAKE_SOURCE_DIR}/thirdParty/yaml-cpp/build/aarch64lib/include)
    link_directories(${CMAKE_SOURCE_DIR}/thirdParty/yaml-cpp/build/aarch64lib/lib)

    include_directories(${CMAKE_SOURCE_DIR}/thirdParty/bluez/aarch64lib/include)
    link_directories(${CMAKE_SOURCE_DIR}/thirdParty/bluez/aarch64lib/lib)
endif()

# include_directories(${CMAKE_SOURCE_DIR}/threadPool)
# include_directories(${CMAKE_SOURCE_DIR}/modbus)
# include_directories(${CMAKE_SOURCE_DIR}/mqtt)
# include_directories(${CMAKE_SOURCE_DIR}/utils)
# include_directories(${CMAKE_SOURCE_DIR}/device/point)
# include_directories(${CMAKE_SOURCE_DIR}/device/dev)
# include_directories(${CMAKE_SOURCE_DIR}/device/manager)
# include_directories(${CMAKE_SOURCE_DIR}/device/devUpgradeGuard)
# include_directories(${CMAKE_SOURCE_DIR}/thirdParty/spdlog)
# include_directories(${CMAKE_SOURCE_DIR}/thirdParty/json/single_include/nlohmann)
# include_directories(${CMAKE_SOURCE_DIR}/msgObject)
# include_directories(${CMAKE_SOURCE_DIR}/mainProcess)
# include_directories(${CMAKE_SOURCE_DIR}/blue)



add_definitions(-DLOG_FILE_NAME="/home/test/hehehe.log")
add_definitions(-DMODBUS_VERSION="V1.0.0")

add_definitions(-DREAD_POINT_CHANGE_REPORT) # 读点变化上报？

add_definitions(-DCONSOLE_LOG_ENABLE)

add_definitions(-DMQTT_LOG_ENABLE)
add_definitions(-DMODBUS_LOG_ENABLE)
add_definitions(-DMAIN_LOG_ENABLE)
add_definitions(-DBLUETOOTH_LOG_ENABLE)

aux_source_directory(${CMAKE_SOURCE_DIR} SRC)

add_executable(${CMAKE_PROJECT_NAME})

target_sources(${CMAKE_PROJECT_NAME} PUBLIC ${SRC})

target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC utils)
target_include_directories(${CMAKE_PROJECT_NAME} BEFORE PUBLIC thirdParty/json/single_include/nlohmann)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC threadPool)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC modbus)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC mqtt)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC device/devUpgradeGuard)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC device/fileGuard)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC device/point)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC device/dev)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC device/manager)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC thirdParty/spdlog)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC msgObject)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC mainProcess)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC blue)

target_link_libraries(${CMAKE_PROJECT_NAME} pthread modbus mosquitto yaml-cpp bluetooth)



add_subdirectory(${CMAKE_SOURCE_DIR}/test)
add_subdirectory(${CMAKE_SOURCE_DIR}/testYaml)